package com.atguigu.responsibilityChain;

/**
 * @program: design-patterns
 * @author: yangshen
 * @description:
 * @create: 2022-04-06 00:41
 **/
public class Client {
    public static void main(String[] args) {
        //创建2个请求
        PurchaseRequest purchaseRequest1 = new PurchaseRequest(1, 31000, 1);
        PurchaseRequest purchaseRequest2 = new PurchaseRequest(2, 1000, 2);

        //创建相关的审批人
        DepartmentApprover departmentApprover = new DepartmentApprover("系主任");
        CollegeApprover collegeApprover = new CollegeApprover("学院院长");
        ViceSchoolMaterApprover viceSchoolMaterApprover = new ViceSchoolMaterApprover("副校长");
        SchoolMaterApprover schoolMaterApprover = new SchoolMaterApprover("校长");

        //1.需要将各个审批级别的下一个设置好
        departmentApprover.setApprover(collegeApprover);
        collegeApprover.setApprover(viceSchoolMaterApprover);
        viceSchoolMaterApprover.setApprover(schoolMaterApprover);
        //2.将校长的下一个审批人设置为系主任，审批处理人形成环形（也可以不设置，单线审批）
        schoolMaterApprover.setApprover(departmentApprover);

        departmentApprover.processRequest(purchaseRequest1);
        schoolMaterApprover.processRequest(purchaseRequest2);
    }
}
